package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Ygrecord;
import com.ruoyi.system.service.IYgrecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人选管理操作记录Controller
 *
 * @author ruoyi
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/system/ygrecord")
public class YgrecordController extends BaseController
{
    @Autowired
    private IYgrecordService ygrecordService;

    /**
     * 查询人选管理操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:ygrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(Ygrecord ygrecord)
    {
        List<Ygrecord> list = ygrecordService.selectYgrecordList(ygrecord);
        return getDataTable(list);
    }

    /**
     * 导出人选管理操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:ygrecord:export')")
    @Log(title = "人选管理操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Ygrecord ygrecord)
    {
        List<Ygrecord> list = ygrecordService.selectYgrecordList(ygrecord);
        ExcelUtil<Ygrecord> util = new ExcelUtil<Ygrecord>(Ygrecord.class);
        util.exportExcel(response, list, "人选管理操作记录数据");
    }

    /**
     * 获取人选管理操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ygrecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(ygrecordService.selectYgrecordByRecordId(recordId));
    }

    /**
     * 新增人选管理操作记录
     */
    @PreAuthorize("@ss.hasPermi('system:ygrecord:add')")
    @Log(title = "人选管理操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ygrecord ygrecord)
    {
        return toAjax(ygrecordService.insertYgrecord(ygrecord));
    }

    /**
     * 修改人选管理操作记录
     */
    @PreAuthorize("@ss.hasPermi('system:ygrecord:edit')")
    @Log(title = "人选管理操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ygrecord ygrecord)
    {
        return toAjax(ygrecordService.updateYgrecord(ygrecord));
    }

    /**
     * 删除人选管理操作记录
     */
    @PreAuthorize("@ss.hasPermi('system:ygrecord:remove')")
    @Log(title = "人选管理操作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(ygrecordService.deleteYgrecordByRecordIds(recordIds));
    }
}
